﻿using CommonServiceLocator;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using Memorandum.Models;
using Memorandum.Service;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Memorandum.ViewModel
{
   public class HomeViewModel : ViewModelBase
    {
        public HomeViewModel(INavigationService srvice)
        {
            INav = srvice;
            init();
        }
        private INavigationService INav;
        private void init()
        {
            Task.Run(() =>
            {
                while (true)
                {
                    Time = DateTime.Now.ToString("HH:mm:ss");
                    Thread.Sleep(1000);
                }

            });
   
            dialyCommand = new RelayCommand(() => {
              var vm=  ServiceLocator.Current.GetInstance<MainViewModel>();
                vm.DisplayPage = INav.Navigate( new Uri("views/DailyRemind.xaml", UriKind.Relative));
            });
            remindCommand = new RelayCommand(() => {
                var vm = ServiceLocator.Current.GetInstance<MainViewModel>();
                vm.DisplayPage = INav.Navigate(new Uri("views/Remind.xaml", UriKind.Relative));
            });
            remindListCommand = new RelayCommand(() => {
                Messenger.Default.Send("Message", Message.ShowWait);
                var vm = ServiceLocator.Current.GetInstance<MainViewModel>();
                    vm.DisplayPage = INav.Navigate(new Uri("views/RemindList.xaml", UriKind.Relative));
              
             
            });
        }
        private string time;

        public string Time
        {
            get { return time; }
            set
            {
                Set(ref time, value);
            }
        }
        private ObservableCollection<TitleItemModel> itemSet = new ObservableCollection<TitleItemModel>();

        public ObservableCollection<TitleItemModel> TCollection
        {
            get { return itemSet; }

        }
        private ICommand dialyCommand;

        public ICommand DailyCommand
        {
            get { return dialyCommand; }
            set
            {
                Set(ref dialyCommand, value);
            }
        }

        private ICommand remindCommand;

        public ICommand RemindCommand
        {
            get { return remindCommand; }
            set
            {
                Set(ref remindCommand, value);
            }
        }

        
       private ICommand remindListCommand;

        public ICommand RemindListCommand
        {
            get { return remindListCommand; }
            set
            {
                Set(ref remindListCommand, value);
            }
        }

    }
}
